
var initial = -120;
var imageWidth=240;
var eachPercent = (imageWidth/2)/100;

/***************************************************************\
*
\***************************************************************/

function setValue(id, id2){
	
	document.getElementById(id).value = document.getElementById(id2+'Text').innerHTML;		
}

/************************************************************\
*
\************************************************************/
function setText (id, percent)
{
    document.getElementById(id+'Text').innerHTML = percent;
}
/************************************************************\
*
\************************************************************/
function display ( id, percentage,color )
{	
	if (typeof color == "undefined") {
    color = "1";
  	}
    
    document.write('<div style="float:left; width:100px; background:url(/././app/themes/default/images/percent/bramus/percentImage.png);"><div style="width:'+percentage+'px; height:12px;background: url(/././app/themes/default/images/percent/bramus/percentImage_back'+color+'.png) repeat-x" id="'+id+'"></div></div> <div id="'+id+'Text" style="width: 22px; float:left; padding-left:10px;">'+percentage+'</div><div style="width:18px; float:left;">%</div>');
}
/************************************************************\
*
\************************************************************/
function emptyProgress(id)
{   
    document.getElementById(id).style.width = '0px';
    setText(id,'0');
}
/************************************************************\
*
\************************************************************/
function getProgress(id)
{
    var nowWidth = document.getElementById(id).style.backgroundPosition.split("px");
    return (Math.floor(100+(nowWidth[0]/eachPercent)));
	
}
/************************************************************\
*
\************************************************************/
function setProgress(id, percentage)
{

   	plus(id,percentage);
    setText(id,percentage);
    document.getElementById(id).style.width = percentage;
}
/************************************************************\
*
\************************************************************/

function plus ( id2, percentage )
{
   var str = document.getElementById(id2+"Text").innerHTML;   
   str = str.replace("%","");
   
   if(Number(str) + Number(percentage) < 100)
   	result = Number(str) + Number(percentage);	
   else	   	
   	result = 100;
   	
   document.getElementById(id2).style.width = result;
   document.getElementById(id2+"Text").innerHTML = result; 
   
}
function minus( id2, percentage )
{		
   var str = document.getElementById(id2+"Text").innerHTML;   
   str = str.replace("%","");
   if(str - percentage > 0)
   	result = str - percentage;
   else	
   	result = 0;
   document.getElementById(id2).style.width = result;
   document.getElementById(id2+"Text").innerHTML = result;  
}
/************************************************************\
*
\************************************************************/
function fillProgress(id2, endPercent)
{
	plus(id2,endPercent);
  setText(id2,endPercent);        
}

